package com.hd123.rumba.qt.def;

import com.hd123.rumba.exception.BusinessException;

public class SQLJoin {

  /**
   * 返回适用于where子句的表达式
   * 
   * @return
   */
  public String getSQLWhereExpression() throws BusinessException {
    StringBuffer sb = new StringBuffer();
    sb.append(query.translateColumn(getLeft()));
    sb.append(" ");
    sb.append(getOperator());
    sb.append(" ");
    sb.append(query.translateColumn(getRight()));
    return sb.toString();
  }

  public String debugInfo() {
    StringBuffer sb = new StringBuffer();
    sb.append(getClass().getName() + "\n");
    sb.append("Left: " + getLeft() + "\n");
    sb.append("Operator: " + getOperator() + "\n");
    sb.append("Right: " + getRight() + "\n");
    return sb.toString();
  }

  private String left;

  private String operator;

  private String right;

  public String getLeft() {
    return left;
  }

  public void setLeft(String left) {
    this.left = left;
  }

  public String getOperator() {
    return operator;
  }

  public void setOperator(String operator) {
    this.operator = operator;
  }

  public String getRight() {
    return right;
  }

  public void setRight(String right) {
    this.right = right;
  }

  private QueryDefinition query;

  public QueryDefinition getQuery() {
    return query;
  }

  public void setQuery(QueryDefinition query) {
    this.query = query;
  }
}
